/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.uoc.tdp.pac4.only5.gui.client.model;
import edu.uoc.tdp.pac4.only5.domain.User;
import java.util.List;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;
/**
 *
 * @author Gerard/Rafa
 */

public class UserComboBoxModel extends AbstractListModel implements ComboBoxModel {
    
    List<User> elements;
    
    User selectedItem;

    public UserComboBoxModel(List<User> elements) {
        this.elements = elements;
    }
    
    
    @Override
    public int getSize() {
        int i = 0;
        if(elements != null && elements.size() > 0){
            i = elements.size();
        }
        return i;
    }

    @Override
    public Object getElementAt(int i) {
        Object result = null;
        if(elements != null){
            result = elements.get(i);
        }
        return result;
    }

    @Override
    public void setSelectedItem(Object o) {
        selectedItem = (User) o;
    }

    @Override
    public Object getSelectedItem() {
        return this.selectedItem;
    }
    
}
